package kr.co.gruming;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class LoginInfoServlet
 */
@WebServlet("/LoginInfo")
public class LoginInfoServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		response.setContentType("text/html; charset=utf-8");
		PrintWriter out = response.getWriter();

		HttpSession se = request.getSession(false);
		String id = (String) se.getAttribute("userid");

		if (id == "") {
			response.sendRedirect("loginForm.html");
		}
		else {
			String pw = (String) se.getAttribute("passwd");

			out.print("사용자 아이디값 : " + id + "<br>");
			out.print("사용자 비밀번호값 : " + pw + "<br>");

			out.print("<a href='Logout'>로그아웃</a>");
		}
	}

}
